package com.dzl.util.chuanglan.util;

import com.alibaba.fastjson.JSON;
import com.dzl.util.chuanglan.request.SmsVariableRequest;
import com.dzl.util.chuanglan.response.SmsVariableResponse;

public class SmsChuangLanUtil {
	
	public static final String charset = "utf-8";
	// 用户平台API账号(非登录账号,示例:N1234567)
	public static String account = "N0166667";
	// 用户平台API密码(非登录密码)
	public static String pswd = "HgAqRQtXp65afe";
	//请求地址请登录253云通讯自助通平台查看或者询问您的商务负责人获取
	public static String smsSingleRequestServerUrl = "http://smssh1.253.com/msg/send/json";
	public static String smsVariableRequestUrl = "http://smssh1.253.com/msg/variable/json";

    public SmsChuangLanUtil(){}    
    
    /**
     * @author Evan
     * 创蓝，发送短信
     * @param phone 手机号码
     * @param msg 短信内容 如：【253云通讯】你好,你的验证码是123456
     * @param extend 下发短信号码扩展码，纯数字，建议1-3位，选填
     * @return
     */
    /*public static SmsSendResponse sendMsgs(String phone, String msg ,String extend){
    	//状态报告
    	String report= "true";
    			
    	SmsSendRequest smsSingleRequest = new SmsSendRequest(account, pswd, msg, phone,null,report,extend,null);
    			
    	String requestJson = JSON.toJSONString(smsSingleRequest);
    			
    	String response = ChuangLanSmsUtil.sendSmsByPost(smsSingleRequestServerUrl, requestJson);
    			
    	SmsSendResponse smsSingleResponse = JSON.parseObject(response, SmsSendResponse.class);
    	
		return smsSingleResponse;
        
    }*/
    
    /**
     * @author Evan
     * 创蓝，发送短信
     * @param phone 手机号码
     * @param msg 短信内容 如：【253云通讯】你好,你的验证码是123456
     * @param extend 下发短信号码扩展码，纯数字，建议1-3位，选填
     * @return
     */
    public static SmsVariableResponse sendVariableMsg(String msg ,String params){
    	//状态报告
    	String report= "true";
    			
    	SmsVariableRequest smsVariableRequest=new SmsVariableRequest(account, pswd, msg, params,report);
    			
    	String requestJson = JSON.toJSONString(smsVariableRequest);
    			
    	String response = ChuangLanSmsUtil.sendSmsByPost(smsVariableRequestUrl, requestJson);
    			
    	SmsVariableResponse smsVariableResponse = JSON.parseObject(response, SmsVariableResponse.class);
    	
		return smsVariableResponse;
        
    }
    

}
